package com.bj58.ecdata.mailreport.service.impl;

import java.util.List;

import com.bj58.ecdata.mailreport.db.CommonDao;
import com.bj58.ecdata.mailreport.db.DBConfig;
import com.bj58.ecdata.mailreport.model.IESend;
import com.bj58.ecdata.mailreport.model.IESendRecord;
import com.bj58.ecdata.mailreport.service.AbstractBaseService;

public class IESendService extends AbstractBaseService<IESend> {
	private CommonDao comDao = new CommonDao();
	
	public List<IESend> getListByCon(String condition) throws Exception {
		String sql = "select * from ie_send where " + condition ;
		return comDao.getAllColsByVo(sql, IESend.class, DBConfig.db_manage.getIntType());
	}

	public IESend getById(int id) throws Exception {
		String sql = "select * from ie_send where id = " + id;
		return comDao.getAllColsByVo(sql, IESend.class, DBConfig.db_manage.getIntType()).get(0);
	}

	public boolean updateVo(IESend vo) throws Exception {
		int res =  comDao.updateByVo("ie_send", "id=" + vo.getId(), IESend.class, vo, DBConfig.db_manage.getIntType());
		return res==0?false:true;
	}

	public IESend getByMainId(int mainId) throws Exception {
		String sql = "select * from ie_send where mainId = " + mainId;
		return comDao.getAllColsByVo(sql, IESend.class, DBConfig.db_manage.getIntType()).get(0);
	}

	public void saveSendRecord(IESendRecord record) {
		try {
			comDao.insertOneByVo(null, "ie_send_record", IESendRecord.class, record, DBConfig.db_manage.getIntType());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
